<%@ taglib prefix="c" uri="/WEB-INF/tlds/hdiv-c.tld"%>
<%@ taglib prefix="form" uri="/WEB-INF/tlds/hdiv-spring-form-3_0_4.tld"%>
<%@ taglib uri="/WEB-INF/tlds/hdiv-spring.tld" prefix="spring"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<c:url value="mostrarHWF3007.html" var="listadoPedidos"/>
<c:url value="seleccionarMatriz.html" var="seleccionarMatriz"/>


<script type="text/javascript">
 
var urlMatrices = '<c:url value="mostrarHWF3007.html"><c:param name="accion" value="showMatrices"/></c:url>'

</script>
<script type="text/javascript">   

    function show_loading(){  
        var loadingAnim = document.getElementById('loading_mostrar');  
        loadingAnim.innerHTML = '<img src="imagenes/logoProcesandoDown.gif" width=' + xx_d + 'height=' + yy_d + 'alt="Procesando" />';  
        loadingAnim.style.display = 'block';      
        }  

    $(document).ready(function(){   
        $("#mostrarExcel").click(function(){$("#accion").attr("value","mostrarExcel") });
        $("#mostrar").click(function(){seguir();});        
        $("#opener_matriz").click(openWinMatriz);
        $("#fechadesde").datepicker();
        $("#fechahasta").datepicker();
        $("#codMatriz").change( function(){ if(  $("#codMatriz").val()!=0 ) $("#opener_matriz").show();else $("#opener_matriz").hide(); });                        
        if($("#codMatriz").val()!=0)$("#opener_matriz").show();else $("#opener_matriz").hide();
    }); 
    
    function openWinMatriz(){
        childWindow=window.showModalDialog('<c:url value="seleccionarMatriz.html" />','selecMatriz',"dialogWidth:680px;dialogHeight:350px");          
    }
    function openwindow(url,winheight,winwidth)
    {
        winwidth='450';
        winheight='920';
        window.open('about:blank', 'window1', 'location=0,directories=0,status=0,scrollbars=1,resizable=1,width='+winwidth+',height='+winheight);        
        var accion = 'mostrarReporte';
        var target = 'window1';
        document.forms[0].accion.value = accion;
        document.forms[0].target = target;
        document.forms[0].submit();
    } 
    function openwindow2(url,winheight,winwidth,accion)
    {
        winwidth='450';
        winheight='920';
        window.open('about:blank', 'window1', 'location=0,directories=0,status=0,scrollbars=1,resizable=1,width='+winwidth+',height='+winheight);    
        var target = 'window1';
        document.forms[0].accion.value = accion;
        document.forms[0].target = target;
        document.forms[0].submit();
    } 
    
    function cursor_wait() {
      document.body.style.cursor = 'wait';
    }
    
    function mostrar(){
    //activar el div procesando con javascript      
      show_loading();
      setTimeout('show_loading();', 1000);
      cursor_wait() ;
       //////
    moveForward('cargarFecha');
    }
    function seguir(){
    if (document.forms[0].fechadesde.value=='' || document.forms[0].fechahasta.value=='') {
        alert('Debe seleccionar los datos solicitados.');
        return false;
    }
    if(!checkDate(document.forms[0].fechadesde)) {
        return false;
    } 
    if(!checkDate(document.forms[0].fechahasta)) {
        return false;
    }
    if(validaRangoFechas(document.forms[0].fechadesde.value, 
                             document.forms[0].fechahasta.value)==false){
           $("#fechahasta").focus();
           return false
    }   
    show_loading();
    setTimeout('show_loading();', 1000);
    cursor_wait() ;
    $("#noData").hide();
    moveForward('mostrar');
    }
    </script>

<style type="text/css">  
<!-- 
#loading_mostrar {display:none;}  
img{
    border: 0;
}
-->  
</style>

<form:form modelAttribute="form" action="${listadoPedidos}">
  <form:hidden path="control"/>  
  <form:hidden path="accion"/>
  <form:hidden path="formulario"/>  
  <form:hidden path="existeCliDest"/>
  <form:hidden path="existeMatriz"/>
  <form:hidden path="cliente"/>
  <form:hidden path="sucursal"/>
  
<!--Favoritos:-->
<input type="hidden" id="codOpci" value="${codOpci}"/>
<input type="hidden" id="desOpci" value="${desOpci}"/>

  <table id="fullheighttable" width="775" cellspacing="0" cellpadding="0" border="0"
         align="center">
    <tr>
      <td align="left" valign="top" class="fondo_contenido padtop16left21">
        <table border="0" cellspacing="0" cellpadding="0"
               class="verdana11bazul">
          <tr>
            <td height="22" align="left" valign="top" class="verdana11bazul">
              <ul class="navlist2">
                <li>LISTADO&nbsp;DE PEDIDOS</li>
              </ul>
            </td>
            <td width="120"> </td>
         <td>
             <a href="#" id="opener_agregarFavoritos"> <img src="images/agregar_favoritos.png" width="25" height="23" border="0" title='Agregar Favoritos'/> </a>
        </td>
          </tr>
          <tr>
            <td align="left" valign="top" class="borde_totalblanco">
              <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="100" height="23" align="left" valign="top"
                      class="verdana10bazul">Cliente</td>
                  <td height="23" align="left" valign="top"
                      class="verdana10negro" width="416">
                    <c:out value="${sessionScope.nombreCliente}"/>
                  </td>
                </tr>
                <!-- Muestra el grupo de clientes en caso de coorporación      -->
                <c:if test="${not empty listaClientes}">                
                  <tr>
                    <td width="100" height="23" align="left" valign="top"
                        class="verdana10bazul">Grupo Cliente</td>
                    <td width="416">
                      <form:select cssStyle="height: 20px; width: 180px; font-family: Arial; font-size: 8pt"
                                   path="cli_grupo">
                        <form:option value=""></form:option>
                          <form:options items="${listaClientes}"
                                        itemValue="codCliente"
                                        itemLabel="nombre"/>
                      </form:select>
                    </td>
                  </tr>
                </c:if>
                <tr>
                  <td width="100" height="27" align="left"
                      class="verdana10bazul">Tipo de Pedido</td>
                  <td height="27" align="left" valign="bottom"
                      class="verdana10negro" width="416">
                    <div class="fondo_txtbox90">
                      <form:select cssStyle="height: 20px; width: 180px; font-family: Arial; font-size: 8pt"
                                   path="tipo" cssClass="tipo">
                        <c:if test="${not empty listaTipos}">   
                          <form:options items="${listaTipos}"
                                        itemValue="codigo"
                                        itemLabel="descripcion"/>
                        </c:if>
                      </form:select>
                    </div>
                  </td>
                </tr>
                <c:if test="${form.existeCliDest}">
                  <tr>
                    <td width="100" height="27" align="left"
                        class="verdana10bazul">Tipo Destino</td>
                    <td height="27" align="left" valign="bottom"
                        class="verdana10negro" width="416">
                      <div class="fondo_txtbox90">
                        <form:select cssStyle="height: 20px; width: 180px; font-family: Arial; font-size: 8pt"
                                     path="tipoDestino"
                                     onchange="mostrar()" cssClass="tipoDestino">
                          <form:option value="3">TODOS</form:option>
                          <c:if test="${not empty listadoTiposDestino}">   
                            <form:options items="${listadoTiposDestino}"
                                          itemValue="codigo"
                                          itemLabel="descripcion"/>
                          </c:if>
                        </form:select>
                      </div>
                    </td>
                  </tr>
                </c:if>
                <c:if test="${form.existeMatriz}">
                <tr>
                    <td width="100" height="27" align="left"
                        class="verdana10bazul">Matriz</td>
                    <td height="27" align="left" valign="bottom"
                        class="verdana10negro" width="416">
                        <form:select cssClass="fondo_txtbox63" cssStyle="height: 20px; width: 180px; font-family: Arial; font-size: 8pt"
                                     path="codMatriz">
                          <form:option value="0">TODOS</form:option>
                          <form:option value="1">ALGUNOS</form:option>
                        </form:select>
                        <a href="#" id="opener_matriz"><img src="images/search.png" width="17px" height="17px" title="Buscar"/> </a>
                    </td>
                  </tr>
                </c:if>
                <tr>
                  <td height="34" align="left" class="verdana10bazul"
                      width="100">Fecha Solicitud</td>
                  <td height="34" align="left" class="verdana10negro"
                      width="416">
                    <table border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td align="center" valign="bottom" class="padright10">
                          <div class="fondo_txtbox90">                             
                            <form:input path="fechadesde" maxlength="10" size="12" cssClass="fechadesde" />
                          </div>
                        </td>
                        <td class="verdana10bazul">&nbsp;al&nbsp;&nbsp;</td>
                        <td align="center" valign="bottom" class="padright10">
                          <div class="fondo_txtbox90">
                            <form:input path="fechahasta" maxlength="10"
                                       size="12"/>
                          </div>
                        </td>
                        <td width="140" align="right" valign="middle">
                          <input type="button" class="boton" value="Mostrar" id="mostrar"/>                          
                        </td>
                      </tr>
                      <tr>
                        <td colspan="4"></td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
              <tr>
                    <td colspan="6" align="center">    
                    <div id="loading_mostrar"><img id="logoDown" src="imagenes/logoProcesandoDown.gif" alt="Procesando" /></div>  
                    </td>
              </tr>       
        </table>
        <c:if test="${not empty listaModulos}">  
          <table border="0" cellpadding="0" cellspacing="0" class="margintop20">
            <tr>
              <td width="100%">
                <display:table id="lista" name="listaModulos" cellpadding="0"
                               cellspacing="0" style="width:96%" pagesize="10"
                               requestURI="mostrarHWF3007.html" class="its7">
                  <tbody>
                    <display:column property="fec_soli_pedi" headerClass="even"
                                    class="cellcenter "
                                    title="Fecha Solicitud"/>
                    <display:column property="hor_soli" headerClass="even"
                                    class="cellcenter " title="Hora"/>
                    <display:column property="cod_seri_pedi" headerClass="even"
                                    class="cellcenter " title="Serie"/>
                    <display:column property="num_pedi" headerClass="even"
                                    class="cellcenter " title="Pedido"/>
                    <display:column property="cod_cnta_orig" headerClass="even"
                                    class="cellcenter " title="Cnta"/>
                    <c:if test="${form.existeMatriz}">
                    <display:column property="matriz" headerClass="even"
                                    class="even" title="Matriz"/>
                    </c:if>
                    <display:column property="des_punt" headerClass="even"
                                    class="even" title="Agencia"/>
                    <display:column property="fec_proc_aper" headerClass="even"
                                    class="cellcenter " title="Fecha Contable"/>
                    <display:column property="fec_aten_pedi" headerClass="even"
                                    class="cellcenter " title="Fecha Atenci&oacute;n"/>
                    <display:column property="hor_aten" headerClass="even"
                                    class="cellcenter " title="Hora"/>
                    <display:column property="des_bove_cort" headerClass="even"
                                    class="cellcenter" title="B&oacute;veda"/>
                    <display:column property="tip_bill" headerClass="even"
                                    class="cellcenter" title="Tipo Bill."/>
                    <display:column property="unidad" headerClass="even"
                                    class="cellcenter " title="Und."/>
                    <display:column property="mon_pedi" headerClass="even"
                                    class="cellderecha " title="Monto"/>
                    <display:column property="fec_recp" headerClass="even"
                                    class="cellcenter "
                                    title="Fecha Recepci&oacute;n"/>
                    <display:column property="hor_recp" headerClass="even"
                                    class="cellcenter " title="Hora"/>
                    <display:column property="cod_usua_recp" headerClass="even"
                                    class="even " title="Usuario"/>
                  </tbody>
                </display:table>
              </td>
            </tr>
            <tr>
              <td></td>
            </tr>
            <tr>
              <td align="right">
                <table width="45%" border="0" cellpadding="0" cellspacing="0">
                  <tbody>
                    <tr>
                      <td width="60%" align="right" class="verdana11bazul">
                      <c:if test="${not empty listMontos}"> 
                        <c:forEach items="${listMontos}" var="listMontos">
                            <tr>
                                <td class="verdana11bazul"><c:out value="${listMontos.mensaje}"/></td>
                                <td class="verdana11bazul"><c:out value="${listMontos.montoDeno}"/></td>
                            </tr>
                        </c:forEach>
                    </c:if>                    
                      </td>
                    </tr>

                  </tbody>
                </table>
              </td>
            </tr>
          </table>
          <table border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="51" align="left" valign="bottom">
                <input type="button" class="boton" value="Generar Reporte" onclick="openwindow('holas',450,920);"/>
                <input type="button" class="boton" id = "generarExcel" value="Generar Excel" onclick="openwindow2('holas',450,920, 'mostrarExcel');"/>
              </td>
            </tr>
          </table>
        </c:if>
        <c:if test="${empty listaModulos}">  
        <table id="noData">
            <tr>
                <td>
                    No se encontraron registros
                </td>
            </tr>
        </table>
        </c:if>
      </td>
    </tr>  
 
   </table>
</form:form>